package com.iss.apartmentmanage.config.security;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 配置前后端分离跨域
 * Created by sihang on 2020/4/27.
 */
@Configuration
public class CorsConfig implements WebMvcConfigurer {

    /**
     * 允许跨域的源
     */
   // private static String origins = "*";

    /**
     * 页面跨域访问Controller过滤
     *
     * @return
     */
//    @Override
//    public void addCorsMappings(CorsRegistry registry) {
//        WebMvcConfigurer.super.addCorsMappings(registry);
//        registry.addMapping("/**")
//                .allowedHeaders("*")
//                .allowedMethods("*")
//                .allowedOrigins(origins);
//    }
    @Override
    public void addCorsMappings(CorsRegistry registry) {
        WebMvcConfigurer.super.addCorsMappings(registry);
        registry.addMapping("/**")
                .allowedHeaders("*")
                .allowedMethods("*");

    }
}
